package com.jy.adscm.operation.aftersales.service.impl;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.mapper.Wrapper;
import com.jy.adscm.bean.system.JyUser;
import com.jy.adscm.operation.aftersales.bean.ShRepairProecss;
import com.jy.adscm.operation.aftersales.mapper.mysql.ShRepairProecssMapper;
import com.jy.adscm.operation.aftersales.service.ShRepairProecssService;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.jy.adscm.operation.mscyb.bean.JqbzAssembly;
import com.jy.adscm.system.mapper.mysql.JyUserMapper;
import com.jy.adscm.utils.AdscmBaseUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 维修装配过程 服务实现类
 * </p>
 *
 * @author zyl
 * @since 2019-08-22
 */
@Service
public class ShRepairProecssServiceImpl extends ServiceImpl<ShRepairProecssMapper, ShRepairProecss> implements ShRepairProecssService {
     @Autowired
    JyUserMapper jyUserMapper;
    @Override
    public List<ShRepairProecss> selectByPid(String pid) {
        Wrapper<ShRepairProecss> wrapper =new EntityWrapper<>();
        wrapper.eq("pid",pid);
        wrapper.orderBy("rank",false);
        List<ShRepairProecss> shRepairProecsses = super.selectList(wrapper);
        for (ShRepairProecss shRepairProecss : shRepairProecsses) {
            JyUser jyUser = jyUserMapper.selectById(shRepairProecss.getCreator());
            if (AdscmBaseUtils.getInstance().isNotEmpty(jyUser,null)){
                shRepairProecss.setCreatorName(jyUser.getName());
            }
        }
        return shRepairProecsses;
    }
}
